package com.lzh.async.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author zhehen.lu
 * @date 2025/8/13 19:48
 */
@ConfigurationProperties(
        prefix = "lzh.async-task"
)
@Component
public class LzhAsyncTaskProperties {
    private Integer corePoolSize = 10;
    private Integer maxPoolSize = 200;
    private Integer queueSize = 10;
    private String threadNamePrefix = "lzhExecutor";
    private Integer keepAliveTime = 10;

    public LzhAsyncTaskProperties() {
    }

    public Integer getCorePoolSize() {
        return this.corePoolSize;
    }

    public Integer getMaxPoolSize() {
        return this.maxPoolSize;
    }

    public Integer getQueueSize() {
        return this.queueSize;
    }

    public String getThreadNamePrefix() {
        return this.threadNamePrefix;
    }

    public Integer getKeepAliveTime() {
        return this.keepAliveTime;
    }

    public void setCorePoolSize(Integer corePoolSize) {
        this.corePoolSize = corePoolSize;
    }

    public void setMaxPoolSize(Integer maxPoolSize) {
        this.maxPoolSize = maxPoolSize;
    }

    public void setQueueSize(Integer queueSize) {
        this.queueSize = queueSize;
    }

    public void setThreadNamePrefix(String threadNamePrefix) {
        this.threadNamePrefix = threadNamePrefix;
    }

    public void setKeepAliveTime(Integer keepAliveTime) {
        this.keepAliveTime = keepAliveTime;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof LzhAsyncTaskProperties)) {
            return false;
        } else {
            LzhAsyncTaskProperties other = (LzhAsyncTaskProperties)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label71: {
                    Object this$corePoolSize = this.getCorePoolSize();
                    Object other$corePoolSize = other.getCorePoolSize();
                    if (this$corePoolSize == null) {
                        if (other$corePoolSize == null) {
                            break label71;
                        }
                    } else if (this$corePoolSize.equals(other$corePoolSize)) {
                        break label71;
                    }

                    return false;
                }

                Object this$maxPoolSize = this.getMaxPoolSize();
                Object other$maxPoolSize = other.getMaxPoolSize();
                if (this$maxPoolSize == null) {
                    if (other$maxPoolSize != null) {
                        return false;
                    }
                } else if (!this$maxPoolSize.equals(other$maxPoolSize)) {
                    return false;
                }

                label57: {
                    Object this$queueSize = this.getQueueSize();
                    Object other$queueSize = other.getQueueSize();
                    if (this$queueSize == null) {
                        if (other$queueSize == null) {
                            break label57;
                        }
                    } else if (this$queueSize.equals(other$queueSize)) {
                        break label57;
                    }

                    return false;
                }

                Object this$threadNamePrefix = this.getThreadNamePrefix();
                Object other$threadNamePrefix = other.getThreadNamePrefix();
                if (this$threadNamePrefix == null) {
                    if (other$threadNamePrefix != null) {
                        return false;
                    }
                } else if (!this$threadNamePrefix.equals(other$threadNamePrefix)) {
                    return false;
                }

                Object this$keepAliveTime = this.getKeepAliveTime();
                Object other$keepAliveTime = other.getKeepAliveTime();
                if (this$keepAliveTime == null) {
                    if (other$keepAliveTime == null) {
                        return true;
                    }
                } else if (this$keepAliveTime.equals(other$keepAliveTime)) {
                    return true;
                }

                return false;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof LzhAsyncTaskProperties;
    }

    @Override
    public int hashCode() {
        int result = 1;
        Object $corePoolSize = this.getCorePoolSize();
        result = result * 59 + ($corePoolSize == null ? 43 : $corePoolSize.hashCode());
        Object $maxPoolSize = this.getMaxPoolSize();
        result = result * 59 + ($maxPoolSize == null ? 43 : $maxPoolSize.hashCode());
        Object $queueSize = this.getQueueSize();
        result = result * 59 + ($queueSize == null ? 43 : $queueSize.hashCode());
        Object $threadNamePrefix = this.getThreadNamePrefix();
        result = result * 59 + ($threadNamePrefix == null ? 43 : $threadNamePrefix.hashCode());
        Object $keepAliveTime = this.getKeepAliveTime();
        result = result * 59 + ($keepAliveTime == null ? 43 : $keepAliveTime.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "LzhAsyncTaskProperties(corePoolSize=" + this.getCorePoolSize() + ", maxPoolSize=" + this.getMaxPoolSize() + ", queueSize=" + this.getQueueSize() + ", threadNamePrefix=" + this.getThreadNamePrefix() + ", keepAliveTime=" + this.getKeepAliveTime() + ")";
    }
}
